﻿using PC.AzureMultiApp.WebRoleMultiApp.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using System.Web.Mvc;
using PC.AzureMultiApp.Core.Models;
using PC.AzureMultiApp.Storage.Moles;
using PC.AzureMultiApp.Storage;
using PC.AzureMultiApp.Core.Moles;
using PC.AzureMultiApp.Core.Applications.Moles;

namespace PC.AzureMultiApp.WebRoleMultiApp.Tests
{
    
    
   
    [TestClass()]
    public class CreateControllerTest
    {
 
        [TestMethod]
        [HostType("Moles")]
        public void CreateTest()
        {
            CreateController controller = new CreateController();
            ViewResult result = controller.Create() as ViewResult;
            Assert.IsNotNull(result);
        }

        [TestMethod]
        [HostType("Moles")]
        public void CreateAppTest()
        {
            CreateController controller = new CreateController();

            bool notify = false;
            MDeploymentManager.NotifyApplicationModelBoolean = (a, b) 
                =>
                {
                    notify = true;
                };

            bool called = false;
            MApplications.InsertApplicationModel = (app) 
                => 
                {
                    Assert.IsNotNull(app);
                    Assert.IsFalse(app.IsWebDeploy);
                    called = true;
                };

            ApplicationModel newApp = new ApplicationModel();
            newApp.IsWebDeploy = false;

            // Act
            controller.Create(newApp);

            // Assert
            Assert.IsTrue(notify);
            Assert.IsTrue(called);
        }

    }
}
